home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
mus
/
play
/
MP132src.lha
/
settingswin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-14
|
8KB
|
368 lines
/*
* MultiPlayer
* Copyright (C) 1992 Bryan Ford
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* I (the author of MultiPlayer) can be contacted on the Internet at
* "bryan.ford@m.cc.utah.edu". See "Player.doc" for other addresses.
*
* $Id: settingswin.c,v 4.3 92/07/19 18:07:58 BAF Exp $
*
* $Log: settingswin.c,v $
* Revision 4.3 92/07/19 18:07:58 BAF
* Adjustment for putting localdata back into RemindNodes
*
* Revision 4.2 92/06/21 11:12:42 BAF
* Migrated regargs to stdargs
*
* Revision 4.1 92/06/06 19:56:36 BAF
* Major_code_cleanup
*
* Revision 3.1 92/05/25 07:53:14 BAF
* GNU-ized.
*
*
*/
#include <exec/types.h>
#include <exec/execbase.h>
#include <intuition/intuition.h>
#include <libraries/asl.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/wb.h>
#include "bry/macros.h"
#include "bry/remind.h"
#include "bry/misc.h"
#include "bry/guido.h"
#include "player.h"
extern GuidoSpec settingswindowspec;
extern short settingswinleft, settingswintop;
extern struct MPWin mpwin;
struct Gadget *settingsmodgad, *settingsvolumegad,
*settingsbalancegad, *settingsbalanceresetgad,
*settingsspeedgad, *settingsntscgad, *settingspalgad,
*settingsendgad, *settingsendsetgad, *settingsendcleargad,
*settingsfiltergad,
*settingstempogad, *settingsendfadegad;
static long check(long sigmask);
void settingswinupdate(void);
static void totalupdate(void);
static struct ModNode *oldmod;
static short oldvol, oldbal, oldspeed;
static char oldfilter;
static long oldend;
static struct MPWin mpwin = {settingswindowspec,&settingswinleft,totalupdate,
{0},{{0},check},{0}};
static long
check(long sigmask)
{
if((sigmask & mpwin.sigmask) && GCheckPanel(mpwin.win,standardcallback,0L))
setfinmpwin(&mpwin);
return(0);
}
static void
showend(void)
{
if(!mpwin.win || !selmod)
return;
if(selmod->endtime)
{
extern struct ExecBase *SysBase;
static char buf[32];
long endtime = selmod->endtime/SysBase->VBlankFrequency;
sprintf(buf,"%ld:%02ld:%02ld",
endtime/(60*60),
(endtime/60)%60,
endtime%60);
GSetText(mpwin.win,settingsendgad,buf);
}
else
GSetText(mpwin.win,settingsendgad,"(none)");
}
static void
showspeed(void)
{
if(!mpwin.win || !selmod)
return;
if(selmod->speed)
GSetSliderLevel(mpwin.win,settingsspeedgad,selmod->speed);
}
static void
settingschanged(void)
{
if(selmod)
GlobPostMod(&selmod,settingswinupdate);
}
void
gui_settingsvolume(struct GuidoMessage *gm)
{
if((selmod) && (selmod->volume >= 0))
selmod->volume = oldvol = gm->Code,
settingschanged();
}
void
gui_settingsbalance(struct GuidoMessage *gm)
{
if((selmod) && (selmod->volume >= 0))
selmod->balance = oldbal = gm->Code,
settingschanged();
}
void
gui_settingsbalancereset(struct GuidoMessage *gm)
{
if((selmod) && (selmod->volume >= 0))
selmod->balance = oldbal = 0,
settingschanged();
GSetSliderLevel(mpwin.win,settingsbalancegad,0);
}
static void
speed(int speed)
{
if((selmod) && (selmod->speed))
selmod->speed = oldspeed = speed,
settingschanged();
}
void
gui_settingsspeed(struct GuidoMessage *gm)
{
speed(gm->Code);
}
void
gui_settingspal(struct GuidoMessage *gm)
{
speed(50);
showspeed();
}
void
gui_settingsntsc(struct GuidoMessage *gm)
{
speed(60);
showspeed();
}
void
gui_settingsendset(struct GuidoMessage *gm)
{
extern long songtime;
if(selmod)
selmod->endtime = songtime,
showend(),
settingschanged();
}
void
gui_settingsendclear(struct GuidoMessage *gm)
{
if(selmod)
selmod->endtime = 0,
showend(),
settingschanged();
}
void
gui_settingsfilter(struct GuidoMessage *gm)
{
if((selmod) && (selmod->filter >= 0))
selmod->filter = oldfilter = gm->Code,
settingschanged();
}
void
gui_settingsendfade(struct GuidoMessage *gm)
{
if((selmod) && (selmod->volume >= 0))
{
if(GGetCheckboxChecked(settingsendfadegad))
selmod->flags |= MNF_ENDFADE;
else
selmod->flags &= ~MNF_ENDFADE;
settingschanged();
}
}
void
gui_settingstempo(struct GuidoMessage *gm)
{
if((selmod) && !(selmod->flags & MNF_NOTPROTRACKER))
{
if(GGetCheckboxChecked(settingstempogad))
selmod->flags |= MNF_PTTEMPO;
else
selmod->flags &= ~MNF_PTTEMPO;
settingschanged();
}
}
void
gui_settingsok(void)
{
setfinmpwin(&mpwin);
}
void
gui_settingscurrent(void)
{
GlobSetLong(&selmod,curmod,0L);
}
static void
resetold(void)
{
oldfilter = oldvol = oldbal = oldspeed = 120;
oldend = -1;
oldmod = 0;
}
void settingswinupdate(void)
{
struct Window *win = mpwin.win;
int endis;
if(!win)
return;
if(selmod)
{
if(oldmod != selmod)
GSetText(win,settingsmodgad,selmod->nameptr);
// Volume settings
if(selmod->volume >= 0)
GSetCheckboxChecked(win,settingsendfadegad,(selmod->flags & MNF_ENDFADE) != 0);
if((oldvol != selmod->volume) || (oldbal != selmod->balance))
{
endis = 0;
if(selmod->volume >= 0)
{
GSetSliderLevel(win,settingsvolumegad,selmod->volume);
GSetSliderLevel(win,settingsbalancegad,selmod->balance);
endis = 1;
}
GEnDisGadgets(win,endis,
settingsvolumegad,
settingsbalancegad,
settingsbalanceresetgad,
settingsendfadegad,
0L);
oldvol = selmod->volume;
oldbal = selmod->balance;
}
/* Speed settings */
if(oldspeed != selmod->speed)
{
showspeed();
GEnDisGadgets(win,selmod->speed,settingsspeedgad,settingsntscgad,settingspalgad,0L);
oldspeed = selmod->speed;
}
/* Song end */
if(oldend != selmod->endtime)
{
showend();
oldend = selmod->endtime;
}
GEnDisGadget(win,curmod == selmod,settingsendsetgad);
GEnDisGadget(win,1,settingsendcleargad);
/* Filter */
if(oldfilter != selmod->filter)
{
endis = 0;
if(selmod->filter >= 0)
GSetCycleActive(win,settingsfiltergad,selmod->filter),
endis = 1;
GEnDisGadget(win,endis,settingsfiltergad);
oldfilter = selmod->filter;
}
/* Protracker tempo commands */
endis = 0;
if(!(selmod->flags & MNF_NOTPROTRACKER))
GSetCheckboxChecked(win,settingstempogad,selmod->flags & MNF_PTTEMPO),
endis = 1;
GEnDisGadget(win,endis,settingstempogad);
}
else
{
GSetText(win,settingsmodgad,"");
GSetText(win,settingsendgad,"");
GEnDisGadgets(win,0,
settingsvolumegad,
settingsbalancegad,
settingsbalanceresetgad,
settingsspeedgad,
settingsntscgad,
settingsendsetgad,
settingsendcleargad,
settingsfiltergad,
settingspalgad,
settingsendfadegad,
settingstempogad,
0L);
resetold();
}
oldmod = selmod;
}
static void
totalupdate(void)
{
resetold();
settingswinupdate();
}
char *
settingswinopenclose(void)
{
if(mpwin.win)
{
setfinmpwin(&mpwin);
return(0L);
}
return(openmpwin(&mpwin));
}
void
gui_settingswinopenclose(void)
{
showerr(settingswinopenclose());
}